home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 8 / The Arsenal Files Collection #8 (Arsenal Computer) (1996).ISO / prg_gen / jav503.zip / BOX.JAV < prev    next >
Text File  |  1996-03-29  |  1KB  |  85 lines

  1. // -[KeepHeading]-
  2.  
  3.  
  4. // -[Copyright]-
  5.  
  6. /**
  7.  * (c) Copyright 1993-1994. Step Ahead Software Pty Limited. All rights
  8.  * reserved.
  9.  */
  10. import java.lang.*;
  11.  
  12.  
  13. // -[KeepBeforeClass]-
  14. import java.awt.*;
  15.  
  16.  
  17. // -[Class]-
  18.  
  19. /**
  20.  * @jTitle           Box
  21.  * @jOverridability  can be overridden
  22.  * @jDescription
  23.  * Represents boxes in the application.
  24.  * 
  25.  * @see              Shape
  26.  */
  27. public 
  28. class Box extends Shape
  29. {
  30. // -[KeepWithinClass]-
  31.  
  32.  
  33. // -[Fields]-
  34.  
  35.  
  36.  
  37. /**
  38.  * Init height.
  39.  */
  40. protected int h;
  41.  
  42.  
  43.  
  44. /**
  45.  * Init width.
  46.  */
  47. protected int w;
  48.  
  49.  
  50. // -[Methods]-
  51.  
  52. /**
  53.  * Abstract method overridden in derived classes to paint objects.
  54.  */
  55. public void show(Graphics g)
  56. {
  57.     // Get current color
  58.     Color oldColor = g.getColor();
  59.  
  60.     // Change to yellow
  61.     g.setColor(Color.yellow);
  62.  
  63.     // Draws a circle within the rectangle specified with
  64.     // top, left point and width and height
  65.     g.fillRect(x, y, w, h);
  66.  
  67.     // Restore old color - it's always good practice to leave things the
  68.     // way we found them - think of your kid's future!
  69.     g.setColor(oldColor);    
  70. }
  71.  
  72. /**
  73.  * Constructs a box with the given position and height.
  74.  */
  75. public Box(int initX, int initY, int initWidth, int initHeight)
  76. {
  77.     super(initX, initY);
  78.     w = initWidth;
  79.     h = initHeight;
  80. }
  81.  
  82. }
  83.  
  84.  
  85.